﻿using System;
using Component.Track;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace Component.UI
{
    public class ViewManager
    {
        private static GameObject startView;
        private static GameObject selectView;
        private static GameObject gameView;
        private static GameObject pauseView;
        private static GameObject resultView;
        private static GameObject rewardView;

        static ViewManager()
        {
            startView = GameObject.Find("Start Menu");
            selectView = GameObject.Find("Select View");
            gameView = GameObject.Find("Game View");
            pauseView = GameObject.Find("Pause View");
            resultView = GameObject.Find("Result View");
            rewardView = GameObject.Find("Reward View");
        }
        
        public enum ViewType
        {
            None,
            StartView,
            SelectView,
            GameView,
            PauseView,
            ResultView,
            RewardView,
        }
        
        public static void GetIntoStartView(ViewType view, Action<Transform> callback = null)
        {
            gameView.SetActive(false);
            resultView.SetActive(false);
            rewardView.SetActive(false);
            
            switch (view)
            {
                case ViewType.StartView:
                    startView.SetActive(true);
                    break;
                case ViewType.SelectView:
                    selectView.SetActive(true);
                    break;
                case ViewType.GameView:
                    gameView.SetActive(true);
                    break;
                case ViewType.PauseView:
                    callback?.Invoke(pauseView.transform);
                    break;
                case ViewType.ResultView:
                    resultView.SetActive(true);
                    break;
                case ViewType.RewardView:
                    rewardView.SetActive(true);
                    gameView.SetActive(true);
                    break;
            }
        }

        public static void SetPauseViewPoint(Vector2 pos)
        {
            pauseView.transform.position = pos;
        }
        
    }
}